/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.util.Collections;
import javafx.collections.ObservableList;
import javafx.scene.control.ComboBox;

/**
 *
 * @author Joseph
 */
public class ComboBoxValidation {

    public static void setRed(ComboBox cb) {
        ObservableList<String> styleClass = cb.getStyleClass();
        if (!styleClass.contains("cberror")) {
            if (cb.getValue() == null) {
                styleClass.add("cberror");
            }
        } else if (styleClass.contains("cberror") && cb.getValue() != null) {
            removeRed(cb);
        }
    }

    public static void removeRed(ComboBox cb) {
        ObservableList<String> styleClass = cb.getStyleClass();
        styleClass.removeAll(Collections.singleton("cberror"));
    }

    private ComboBoxValidation() {
    }
}
